package com.qingcheng.dao;

import com.qingcheng.pojo.goods.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SkuMapper extends Mapper<Sku> {
    /**
     * 减少库存
     * @param id
     * @param num
     */
    @Update("update tb_sku set num=num-#{num} where id=#{id}")
    public void decrStore(@Param("id") String id, @Param("num") Integer num);

    /**
     * 添加销量
     * @param id
     * @param num
     */
    @Update("update tb_sku set sale_num=sale_num+#{num} where id=#{id}")
    public void incrSaleNum(@Param("id") String id, @Param("num") Integer num);
    @Select("select id from tb_sku where spu_id=#{spuId}")
    public List<String> findIdsBySpuId(@Param("spuId") String spuId);

}
